package com.jianz.campus_markets.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
 
@Configuration
public class RestTemplateConfig {
 
    @Bean
    public RestTemplate restTemplate() {
        SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
        requestFactory.setConnectTimeout(60000);
        requestFactory.setReadTimeout(60000);
        //使用okhttp
        //RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory());
        RestTemplate restTemplate = new RestTemplate(requestFactory);
        return restTemplate;
    }
 
}